home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Frameworks / Grant's CGI Framework 1.0b14 / Interface / DialogFunc.c < prev    next >
Text File  |  1996-04-11  |  2KB  |  74 lines

  1. /*****
  2.  *
  3.  *    DialogFunc.c
  4.  *
  5.  *    This is a support file for "Grant's CGI Framework".
  6.  *    Please see the license agreement that accompanies the distribution package
  7.  *    for licensing details.
  8.  *
  9.  *    Copyright ©1995,1996 by Grant Neufeld
  10.  *    grant@acm.com
  11.  *    http://arpp.carleton.ca/grant/mac/grantscgi/
  12.  *
  13.  *****/
  14.  
  15. #include "MyConfiguration.h"
  16. #if kCompileWithForeground
  17.  
  18. #include <Threads.h>
  19.  
  20. #include "compiler_stuff.h"
  21. #include "constants.h"
  22. #include "globals.h"
  23.  
  24. #include "Events.h"
  25. #include "WindowInt.h"
  26.  
  27. #include "DialogFunc.h"
  28.  
  29.  
  30. /***  FUNCTIONS  ***/
  31.  
  32. /* This function responds to update, and activate events, and key presses.
  33.     return, enter, Command-. and esc select the 'OK' button (kDefaultButtonID).
  34.     (There's no Cancel button) */
  35. pascal Boolean
  36. defaultAlert1ButtonEventFilter ( DialogPtr theDialog, EventRecord *theEvent, short *itemHit)
  37. {
  38.     Boolean        result;
  39.     char        key;
  40.     short        itemType;
  41.     Handle        itemHandle;
  42.     Rect        itemRect;
  43.     long        finalTicks;
  44.     
  45.     result = false;
  46.     
  47.     switch ( theEvent->what )
  48.     {
  49.         case keyDown :
  50.             key = (char)( theEvent->message & charCodeMask );
  51.             
  52.             if ( (key == (char)kReturnKey) || (key == (char)kEnterKey) ||
  53.                 (key == (char)kEscapeKey) ||
  54.                 ((key == (char)kPeriodKey) && (theEvent->modifiers & cmdKey)) )
  55.             {
  56.                 GetDialogItem    ( theDialog, kDefaultButtonID, &itemType, &itemHandle, &itemRect );
  57.                 HiliteControl    ( (ControlHandle)itemHandle, nil );
  58.                 Delay            ( (long)kVisualDelay, &finalTicks );
  59.                 HiliteControl    ( (ControlHandle)itemHandle, nil );
  60.                 
  61.                 result   = true;
  62.                 *itemHit = (short)kDefaultButtonID;
  63.             }
  64.             break;
  65.     }
  66.     
  67.     return result;
  68. } /* defaultAlert1ButtonEventFilter */
  69.  
  70.  
  71. #endif    /* kCompileWithForeground */
  72.  
  73. /*****  EOF  *****/
  74.